package com.ceres.crops.dao;

import com.ceres.crops.pojo.Crops;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@Repository
public interface CropsMapper extends Mapper<Crops>{

    @Insert("insert into t_crops_index values(null,#{cid},#{iid},#{stage},#{max_range},#{min_range},#{opt_range},#{status})")
    void setCropsAndIndex(Map<String, Object> map);

    @Delete("delete from t_crops_index where cid=#{id}")
    void deleteIndexByCid(Integer id);

    @Update("update t_crops set status = 0 where name=#{name}")
    void delByName(String name);

    /*@Select("select * from t_crops")
    List<Crops> findAll();*/

    @Insert("insert into t_crops_disease values(null,#{cid},#{pid},#{crops},#{pest},#{bad_features},#{disease_range},#{normal_range},#{cure},#{stage},#{status})")
    void setCropsAndPest(Map<String, Object> map);

    @Delete("delete from t_crops_disease where cid=#{id}")
    void deletePestByCid(Integer id);
}
